<?php
class add_article extends UnitTestCase 
{
	var $CI = '';
	
	function add_article() 
	{
		$this->CI =& get_instance();
		$this->CI->load->model('setup/install_model');
		$this->CI->load->model('article_model');
	}
	
	function setUp() 
	{
		$this->CI->install_model->table_articles(TRUE);
		$data = array(
					'article_author' => 1,
					'article_title' => "Búsqueda's",
					'article_uri' => 'cat',
					'article_keywords' => 'cat',
					'article_short_desc' => 'Short Description',
					'article_description' => 'Long Description',
					'article_display' => 'Y'
				);
		$var = $this->CI->article_model->add_article($data);
    }

    function tearDown() 
	{
        $this->CI->install_model->table_articles(TRUE);
    }
 
	function test_add_article() 
	{
	   	$data = array(
					'article_author' => 1,
					'article_title' => "Búsqueda's",
					'article_uri' => 'cat',
					'article_keywords' => 'cat',
					'article_short_desc' => 'Short Description',
					'article_description' => 'Long Description',
					'article_display' => 'Y'
				);
		$var = $this->CI->article_model->add_article($data);
		$this->assertTrue($var);
	}
	
	function test_edit()
	{
		$data = array(
					'article_author' => 1,
					'article_title' => "Búsqueda's",
					'article_uri' => "Búsqueda's",
					'article_keywords' => 'cat',
					'article_short_desc' => 'Short Description',
					'article_description' => 'Example Long Description',
					'article_display' => 'Y'
				);
		$var = $this->CI->article_model->edit_article(1, $data);
		$this->assertTrue($var);
	}
	
	function test_delete()
	{
		$var = $this->CI->article_model->delete_article(1);
		$this->assertTrue($var);
		$var = $this->CI->article_model->delete_article(24);
		$this->assertFalse($var);
	}
	
	function test_hit()
	{
		$var = $this->CI->article_model->add_hit(1);
		$this->assertTrue($var);
		$var = $this->CI->article_model->add_hit(2);
		$this->assertFalse($var);
	}
	function test_foriegn_uri()
	{
		$var = $this->CI->article_model->format_uri('áéíóúàèìòùñäëïöü');
		$this->assertEqual($var, 'aeiouaeiounaeiou');
		$var = $this->CI->article_model->format_uri('áéíóúüñ');
		$this->assertEqual($var, 'aeiouun');
	}
}
